local curMousePos = Point()
local lastMousePos = Point()

function updateCamera(elapsedTime, game, camera)
	local moveSpeed = 40
	local turnspeed = 1/3
	local move = moveSpeed*elapsedTime

	curMousePos = game:getMousePosition()

	if(game:mouseDown(2)) then --VK_RIGHT
		local turnspeedX = (curMousePos.X - lastMousePos.X) * turnspeed
		local turnspeedY = (curMousePos.Y - lastMousePos.Y) * turnspeed
		camera:rotate(turnspeedX, turnspeedY)
	end
	
	lastMousePos = curMousePos
	
	if(game:keyPressed("A")) then
		camera:move(-move, 0, 0)
	elseif(game:keyPressed("D")) then
		camera:move( move, 0, 0)
	end

	if(game:keyPressed("W")) then
		camera:move(0, 0,  move)
	elseif(game:keyPressed("S")) then
		camera:move(0, 0, -move)
	end


	if(game:keyPressed("Q")) then
		camera:move(0,  move, 0)
	elseif(game:keyPressed("E")) then
		camera:move(0, -move, 0)
	end

	camera:update()
end

function handleInput(elapsedTime, game, camera)
	if(game:keyPressed(27)) then --Escape
		game:stop()
	end
	
	updateCamera(elapsedTime, game, camera)
end